package org.example.maven.service.Impl;


import org.example.maven.mapper.eraMapper;
import org.example.maven.pojo.Era;
import org.example.maven.pojo.eCharts.EraDistributionDTO;
import org.example.maven.service.EraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class eraServiceImpl implements EraService {
    @Autowired
    private eraMapper eramapper;
    @Override
    public List<Map<String, String>> getAllEra() {
        List<Map<String,String>> list=new ArrayList<>();
        List<Era> list1=new ArrayList<>();
        list1=eramapper.getAllEra();
        for (Era a:list1){
            Map<String,String> map=new HashMap<>();
            map.put("value", String.valueOf(a.getId()));
            map.put("label", a.getPeriod());
            list.add(map);
        }
        return list;
    }

    @Override
    public List<EraDistributionDTO> getEraByCollection() {
        return eramapper.getEraByCollection();
    }

    @Override
    public String getEraIdByPeriod(String period) {
        return eramapper.getEraIdByEra(period);
    }
}
